package com.lyl.momanapp.activity;

import android.content.Intent;
import android.view.View;
import android.widget.Button;
import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.lyl.momanapp.R;
import com.lyl.momanapp.util.view.MyBaseActivity;

/**
 * 名字 梁亚龙
 * 时间 2017/9/15.
 * QQ邮箱 503934353@qq.com
 * 配送方式页面
 */

public class UserExpressActivity extends MyBaseActivity {

    private CheckBox mCB1;
    private CheckBox mCB2;
    private CheckBox mCB3;
    private Button mBut;

    @Override
    public void initUI() {
        setContentView(R.layout.activity_user_express);
        mCB1 = ((CheckBox) findViewById(R.id.express_cb1));
        mCB2 = ((CheckBox) findViewById(R.id.express_cb2));
        mCB3 = ((CheckBox) findViewById(R.id.express_cb3));
        mBut = ((Button) findViewById(R.id.express_but));
        infoCB();
    }

    private void infoCB() {
        mCB1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b) {
                    mCB2.setChecked(false);
                    mCB3.setChecked(false);
                }
            }
        });
        mCB2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b) {
                    mCB1.setChecked(false);
                    mCB3.setChecked(false);
                }
            }
        });
        mCB3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                if (b) {
                    mCB1.setChecked(false);
                    mCB2.setChecked(false);
                }
            }
        });
    }

    @Override
    public void initData() {

    }

    @Override
    public void addListeners() {
        mBut.setOnClickListener(this);
        findViewById(R.id.fanhui).setOnClickListener(this);
        findViewById(R.id.zhuye).setOnClickListener(this);
    }

    @Override
    public void onClick(View view) {
        switch (view.getId()) {
            case R.id.express_but: {
                finish();
            }
            break;
            case R.id.fanhui:{
                finish();
            }
            break;
            case R.id.zhuye: {

                startActivity(new Intent(UserExpressActivity.this, MainActivity.class));
                finish();
            }
        }
    }

}
